package com.ruoyi.user.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.user.domain.TbBackOfficer;
import com.ruoyi.user.service.ITbBackOfficerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 后台人员管理Controller
 * 
 * @author ruoyi
 * @date 2024-10-15
 */
@RestController
@RequestMapping("/user/officer")
public class TbBackOfficerController extends BaseController
{
    @Autowired
    private ITbBackOfficerService tbBackOfficerService;

    /**
     * 查询后台人员管理列表
     */
    @PreAuthorize("@ss.hasPermi('user:officer:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbBackOfficer tbBackOfficer)
    {
        startPage();
        List<TbBackOfficer> list = tbBackOfficerService.selectTbBackOfficerList(tbBackOfficer);
        return getDataTable(list);
    }

    /**
     * 导出后台人员管理列表
     */
    @PreAuthorize("@ss.hasPermi('user:officer:export')")
    @Log(title = "后台人员管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbBackOfficer tbBackOfficer)
    {
        List<TbBackOfficer> list = tbBackOfficerService.selectTbBackOfficerList(tbBackOfficer);
        ExcelUtil<TbBackOfficer> util = new ExcelUtil<TbBackOfficer>(TbBackOfficer.class);
        util.exportExcel(response, list, "后台人员管理数据");
    }

    /**
     * 获取后台人员管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('user:officer:query')")
    @GetMapping(value = "/{backOfficerId}")
    public AjaxResult getInfo(@PathVariable("backOfficerId") Long backOfficerId)
    {
        return success(tbBackOfficerService.selectTbBackOfficerByBackOfficerId(backOfficerId));
    }

    /**
     * 新增后台人员管理
     */
    @PreAuthorize("@ss.hasPermi('user:officer:add')")
    @Log(title = "后台人员管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbBackOfficer tbBackOfficer)
    {
        return toAjax(tbBackOfficerService.insertTbBackOfficer(tbBackOfficer));
    }

    /**
     * 修改后台人员管理
     */
    @PreAuthorize("@ss.hasPermi('user:officer:edit')")
    @Log(title = "后台人员管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbBackOfficer tbBackOfficer)
    {
        return toAjax(tbBackOfficerService.updateTbBackOfficer(tbBackOfficer));
    }

    /**
     * 删除后台人员管理
     */
    @PreAuthorize("@ss.hasPermi('user:officer:remove')")
    @Log(title = "后台人员管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{backOfficerIds}")
    public AjaxResult remove(@PathVariable Long[] backOfficerIds)
    {
        return toAjax(tbBackOfficerService.deleteTbBackOfficerByBackOfficerIds(backOfficerIds));
    }
}
